<!DOCTYPE HTML>
<html xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/hui/lib/html5shiv.js"></script>
    <script type="text/javascript" src="/hui/lib/respond.min.js"></script>
    <![endif]-->
    <link href="/hui/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="/hui/static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
    <link href="/hui/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/hui/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="/hui/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>🐝注册🐂</title>
    <style>
        .s{
            text-align: center;
        }
    </style>
</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header">
    <h3 class="s"><a href="/sys-user/login">去登录</a></h3>
</div>
<div class="loginWraper">
    <div id="loginform" class="loginBox">
        <form class="form form-horizontal" action="#" method="GET" onsubmit="return false" id="r1">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="name" name="name" type="text" placeholder="姓名" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="username" name="username" type="text" placeholder="账户" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont" id="mi">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="password" name="password" type="password" placeholder="密码" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont" id="mi2">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="repassword" name="repassword" type="password" placeholder="确认密码" class="input-text size-L">
                </div>
            </div>
        </form>
        <form class="form form-horizontal" action="#" method="GET" onsubmit="return false" id="r2" style="display: none">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="tel" name="tel" type="text" placeholder="电话" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="email" name="email" type="email" placeholder="邮箱" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="address" name="address" type="text" placeholder="地址" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="description" name="description" type="text" placeholder="描述" class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <select id="sex">
                        <option value="男" selected="true">男</option>
                        <option value="女">女</option>
                    </select>
                </div>
            </div>
        </form>
        <div class="row cl">
            <div class="formControls col-xs-8 col-xs-offset-3">
                <button type="button" class="btn btn-success radius size-L" onclick="sub()">&nbsp;确&nbsp;&nbsp;&nbsp;&nbsp;认&nbsp;</button>
            </div>
        </div>
    </div>

</div>
<div class="footer">--注册--</div>
<script type="text/javascript" src="/hui/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/hui/static/h-ui/js/H-ui.min.js"></script>
<script>
    var key=0;
    $(function () {
        key=0;
    })
    $("#password,#repassword").keyup(function () {
        if($("#password").val()!=$("#repassword").val()){
            $("#mi,#mi2,#password,#repassword").css("color","red");
        }else {
            $("#mi,#mi2,#password,#repassword").css("color","green");
        }
    })
    
    function sub() {
        switch (key) {
            case 0:
                next();
                break;
            case 1:
                exc();
                break;
            default:
        }
    }
    
    function exc() {
        var yes=confirm("确定要申请这个账号吗？");
        if(yes){
            $.ajax({
                url:"http://localhost:8080/registered/register",
                data:{
                    name:$("#name").val(),
                    username:$("#username").val(),
                    password:$("#password").val(),
                    tel:$("#tel").val(),
                    sex:$("#sex").val(),
                    address:$("#address").val(),
                    state:"0",
                    description:$("#description").val(),
                    email:$("#email").val()
                },
                type:"POST",
                success:function (r) {
                    if(r=="succeed"){
                        confirm("申请注册账号成功！请等待管理员审核！")
                    }else {
                        alert("申请失败！")
                    }
                    location.reload()
                }
            })
        }
    }
    
    
    function next() {
        if($("#password").val()!=$("#repassword").val()||$("#password").val()==""){
            alert("两次密码不能为空且需要一致！");
            return;
        }
        if($("#name").val()==""){
            alert("姓名不能为空！")
            return;
        }
        if($("#username").val()==""){
            alert("您的账号不能为空！")
            return;
        }
        key++;
        $("#r1").hide()
        $("#r2").show()
    }
</script>
</body>
</html>